to_bytes

pure function to_bytes(): byte_array

Convert this big_integer to a byte array.

The first bit of the generated byte array represents the sign (two's complement), and for subsequent bits, more significant bits are on the left and less significant bits are on the left (big-endian).

Inverse of big_integer.from_bytes().

Examples:

  • 0L.to_bytes() returns x'00'

  • (-1L).to_bytes() returns x'FF'

  • 1L.to_bytes() returns x'01'

  • 2L.pow(100).to_bytes() returns x'10000000000000000000000000'

Since

0.12.0